home *** CD-ROM | disk | FTP | other *** search
/ Windows Game Programming for Dummies (2nd Edition) / WinGamProgFD.iso / mac / DirectX SDK / DXSDK / samples / Multimedia / Media / SeaFloor.vsh < prev    next >
Text File  |  2001-10-08  |  2KB  |  63 lines

  1. vs.1.1
  2. ;------------------------------------------------------------------------------
  3. ; Constants specified by the app
  4. ;    c0      = ( 0, 0, 0, 0 )
  5. ;    c1      = ( 1, 0.5, 2, 4 )
  6. ;    c4-c7   = world-view-projection matrix
  7. ;    c8-c11  = world-view matrix
  8. ;    c12-c15 = view matrix
  9. ;    c20     = light direction
  10. ;    c21     = material diffuse color * light diffuse color
  11. ;    c22     = material ambient color
  12. ;    c28     = projection matrix
  13. ;
  14. ; Vertex components (as specified in the vertex DECL)
  15. ;    v0    = Position
  16. ;    v3    = Normal
  17. ;    v6    = Texcoords
  18. ;------------------------------------------------------------------------------
  19.  
  20.  
  21. ;------------------------------------------------------------------------------
  22. ; Vertex transformation
  23. ;------------------------------------------------------------------------------
  24.  
  25. ; Transform to view space (world matrix is identity)
  26. m4x4 r9, v0, c12
  27.  
  28. ; Transform to projection space
  29. m4x4 r10, r9, c28
  30.  
  31. ; Store output position
  32. mov oPos, r10
  33.  
  34.  
  35. ;------------------------------------------------------------------------------
  36. ; Lighting calculation
  37. ;------------------------------------------------------------------------------
  38.  
  39. dp3 r1.x, v3, c20    ; r1 = normal dot light
  40. mul r0, r1.x, c21    ; Multiply with diffuse
  41. add oD0, r0, c22      ; Add in ambient
  42.  
  43.  
  44. ;------------------------------------------------------------------------------
  45. ; Texture coordinates
  46. ;------------------------------------------------------------------------------
  47.  
  48. ; Copy tex coords
  49. mov oT0.xy, v6
  50.  
  51. ;------------------------------------------------------------------------------
  52. ; Fog calculation
  53. ;------------------------------------------------------------------------------
  54.  
  55. ; compute fog factor f = (fog_end - dist)*(1/(fog_end-fog_start))
  56. add r0.x, -r9.z, c23.y
  57. mul r0.x, r0.x, c23.z
  58. max r0.x, r0.x, c0.x       ; clamp fog to > 0.0
  59. min oFog.x, r0.x, c1.x     ; clamp fog to < 1.0
  60.  
  61.  
  62.  
  63.